//index.js
//获取应用实例
var app = getApp()
var special_date = new Date();
special_date.setFullYear("1997");
special_date.setMonth("0");
special_date.setUTCDate("1");
console.log(special_date);
Page({
  data: {
    userInfo: {},
    last_move: null,
    rectangle_width: 25,
    rectangle_height: 25,
    rectangle_x: 25,
    rectangle_y: 25,
    rectangle_pos: null
  },
  //事件处理函数
  bindViewTap: function(event) {
    wx.navigateTo({
      url: '../logs/logs'
    })
  },
  to_ball_page: function(e) {
    wx.navigateTo({
      url: '../ball/ball'
    });
  },
  to_scroll_view: function(e) {
    wx.navigateTo({
      url: '../scroll_view/scroll_view'
    });
  },
  to_2048: function(e) {
    wx.navigateTo({
      url: '../game2048/game2048'
    });
  },
  to_remote: function(e) {
    wx.navigateTo({
      url: '../remote/test'
    });
  },
  bindClearTap: function(event) {
    var logs = [];
    wx.setStorage({
      key: 'logs',
      data: logs
    })
  },
  handle_move: function(e) {
    this.setData({
      rectangle_x: (e.touches[0].pageX-this.data.rectangle_width/2)>0 ? e.touches[0].pageX-this.data.rectangle_width/2 : 0,
      rectangle_y: (e.touches[0].pageY-this.data.rectangle_height/2)>0 ? e.touches[0].pageY-this.data.rectangle_height/2 : 0,
    });
  },
  onLoad: function () {
    // console.log('onLoad');
    var that = this
    //调用应用实例的方法获取全局数据
    app.getUserInfo(function(userInfo){
      //更新数据
      that.setData({
        userInfo:userInfo
      })
    })
  }
})
